import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * @Author Linyh
 * @Description
 * @Date 2022/7/11 15:29
 **/

public class Study {
    //常用函数式接口
    public static void main(String[] args) {

    }
    //Runnable接口
    private static void Runnable接口(){
        int x= 100;
        Runnable r = new Runnable() {
            private int y;
            private void test(){}
            @Override
            public void run() {
                System.out.println("!!!x="+x);
            }
        };
        Runnable r2 = ()->{
            int y = 0;
            System.out.println("!!!x="+x);
        };
        r2.run();
    }

    //function
    private static void Function接口(){
        Function<String,Integer> function1 = str->str.length();
        System.out.println(function1.apply("xxxx"));
        Function<Integer,Integer> function2 = i->i+100;
        System.out.println(function2.compose(function1).apply("xxxx"));
    }

    //简化lambda
    private static void 简化lambda(){
        Consumer<String> con = System.out::println;
        Function<String,Integer> function = Integer::parseInt;
        String str = "abcdefg";
        Function<Integer,String> function2 = str::substring;
        System.out.println(function2.apply(2));
        // BiFunction<String,Integer,Student> biFunction = Student
    }

}
